"""
  模块描述：隐号接受推送的服务端
  @author 8526
  @date 2022-05-13 15:04:01
  版权所有 Copyright www.dahantc.com
"""
import json

from flask import Flask, request
from voice import response as res

import receiveentity as entity

app = Flask(__name__)


@app.route('/hiddenNumCallReceive', methods=['POST'])
def hiddenNumCallReceive():
    status = 'success'
    try:
        axbStartCall = request.form.get('axbStartCall')
        callRes = entity.hiddenNumStartCallResponseDecoder(json.loads(axbStartCall))
        print('收到隐号呼叫推送：', callRes)
    except Exception as e:
        print('数据解析异常 %s' % e)
        status = 'Failure'
    return {'status': status}


@app.route('/hiddenNumReportReceive', methods=['POST'])
def hiddenNumReportReceive():
    status = 'success'
    try:
        voicereport = request.form.get('voicereport')
        reportRes = res.phoneReportResponseDecoder(json.loads(voicereport))
        print('收到隐号报告推送：', reportRes)
    except Exception as e:
        print('数据解析异常 %s' % e)
        status = 'Failure'
    return {'status': status}


if __name__ == '__main__':
    app.run(debug=False, port=8080)
